/**
    Copyright (C) 2011  Alexander Vollmer

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.jefb.dao;

import java.io.Serializable;
import java.util.List;

import javax.persistence.EntityNotFoundException;

import org.hibernate.Session;
import org.jefb.entity.CommonSearchCriteria;

public interface ICommonDao extends Serializable{
	
	public <T> List<T> findByCriteria(T object, CommonSearchCriteria commonCriteria);
	public <T> Long getTotalSizeByCriteria(T searchCriteria);

	// Called to list a objects of a given type within the database
	public abstract <T> List<T> findAll(Class<T> clazz);

	// Called from findAll above
	public abstract <T> T find(Class<T> clazz, Serializable id)
			throws EntityNotFoundException;

	// Called to delete an object from the database
	public abstract <T> T remove(Class<T> clazz, Serializable id)
			throws EntityNotFoundException;

	// Called to add an object to the database
	public abstract <T> void persist(T entity);

	// Called to update an object within the database
	public abstract <T> void merge(T entity);
	
	public <T> List<T> findByExample(T exampleInstance, String... excludeProperty);
	
	public Session getSession();
	
	public void flush();
	
	public <T> T refresh(T entity);

}